package auxiliary;


import java.awt.Graphics;
import java.awt.Image;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

public class BackgroundPanel extends JPanel
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Image tileImage;
	public BackgroundPanel()
	{
		try
		{
			String dir = System.getProperty("user.dir");
			System.out.println(dir+ "\\src\\back.png");
			tileImage = ImageIO.read(new File(dir+ "\\src\\back.png"));

		}
		catch(Exception e){System.out.println("prueba"); e.printStackTrace();}
	}
	
	public void paintComponent(Graphics g) {
	    int width = getWidth();
	    int height = getHeight();
	    int imageW = tileImage.getWidth(this);
	    int imageH = tileImage.getHeight(this);

	    // Tile the image to fill our area.
	    for (int x = 0; x < width; x += imageW) {
	        for (int y = 0; y < height; y += imageH) {
	            g.drawImage(tileImage, x, y, this);
	        }
	    }
	}
}